package model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the election database table.
 * 
 */
@Entity
@NamedQuery(name="Election.findAll", query="SELECT e FROM Election e")
public class Election implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int idElection;

	private int candidates;

	@Temporal(TemporalType.DATE)
	private Date dateElection;

	@Temporal(TemporalType.DATE)
	private Date endCandidacy;

	@Lob
	private String results;

	@Temporal(TemporalType.DATE)
	private Date startCandidacy;

	//bi-directional many-to-one association to Vote
	@OneToMany(mappedBy="election")
	private List<Vote> votes;

	public Election() {
	}

	public int getIdElection() {
		return this.idElection;
	}

	public void setIdElection(int idElection) {
		this.idElection = idElection;
	}

	public int getCandidates() {
		return this.candidates;
	}

	public void setCandidates(int candidates) {
		this.candidates = candidates;
	}

	public Date getDateElection() {
		return this.dateElection;
	}

	public void setDateElection(Date dateElection) {
		this.dateElection = dateElection;
	}

	public Date getEndCandidacy() {
		return this.endCandidacy;
	}

	public void setEndCandidacy(Date endCandidacy) {
		this.endCandidacy = endCandidacy;
	}

	public String getResults() {
		return this.results;
	}

	public void setResults(String results) {
		this.results = results;
	}

	public Date getStartCandidacy() {
		return this.startCandidacy;
	}

	public void setStartCandidacy(Date startCandidacy) {
		this.startCandidacy = startCandidacy;
	}

	public List<Vote> getVotes() {
		return this.votes;
	}

	public void setVotes(List<Vote> votes) {
		this.votes = votes;
	}

	public Vote addVote(Vote vote) {
		getVotes().add(vote);
		vote.setElection(this);

		return vote;
	}

	public Vote removeVote(Vote vote) {
		getVotes().remove(vote);
		vote.setElection(null);

		return vote;
	}

}